<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>过渡练习</title>
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        .search{
            /* width: 240px; */
            /* margin:100px auto; */
            /* outline: 1px solid red; */
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            /* display: inline-block; */
        }
        /* 整个搜索框hover之前 */
        input{
            height: 60px;
            border: none;
            outline: none;
            border-radius: 30px;
            background-color: rgb(193, 252, 144);
            width: 60px;
            transition: 0.5s;
            font-size: 1.2em;
            padding:0 20px;
            background-color: #2f3640;
            color: white;
            box-sizing: border-box;
        }
        
        button{
            width: 40px;
            height: 40px;
            background-color: rgb(255, 62, 62);
            border: none;
            outline: none;
            border-radius: 50%;
            position: absolute;
            right: 10px;
            top: 10px;
            background-color: #2f3640;
            transition: 0.5s;
        }
        /* 整个搜索框hover之前 */
        .search:hover input{
            width: 240px;
            padding-right: 60px;
        }
        .search:hover button{
            background-color: #fff;
        }
        .search button{
            color: #e84118;
        }
    </style>
</head>
<body>
    <div class="search">
        <input type="text">
        <button>
            <i class="fa fa-search"></i>
        </button>
    </div>
</body>
</html>